import { Component, OnInit } from '@angular/core';
import { Recharge } from '../../interfaces/recharge.interfaces';
import { ModalService, Pagination } from 'ng-tui';
import { RechargeService } from '../../services/recharge.service';
import { GlobalService, AuthService } from '../../../../cores/services';
import { HttpConfig } from '../../../../configs/http.config';
import { ApiData, SearchParams } from '../../../../cores/classes';


@Component({
    template: `
    <div class="modal-content">
    <div class="modal-header">
        <h5 class="modal-title">添加部门</h5>
        <button (click)="modal.dismiss()" type="button" class="close">
            <span aria-hidden="true">&times;</span>
        </button>
    </div>
    <div style="border-top: 3px solid #387ddd !important;width: 75px;margin-left: 20px;"></div>
    <div class="modal-body">
        <!--  <div class="form-group row" *ngIf="userInfo.roleId==1&&banner.id==0">
            <label class="col-sm-2 col-form-label label-required text-right" style="padding-right: 0px;">选择公司</label>
            <div class="col-sm-10">
                <select class="form-control pr-int" [(ngModel)]="banner.companyId">
                    <option value="" style="color: #b6b6b6" disabled selected selected="selected">请选择公司</option>
                    <option *ngFor="let item of conpay" [(value)]="item.id">{{item.name}}</option>
                </select>
            </div>
        </div> -->
        <div class="form-group row">
            <label class="col-sm-2 col-form-label label-required text-right" style="padding-right: 0px;">添加部门</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" [(ngModel)]="banner.departmentName" placeholder="请输入部门名称关键词">
            </div>

        </div>
        <div class="form-group row">
            <label class="col-sm-2 col-form-label label-required text-right" style="padding-right: 0px;">部门编码</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" [(ngModel)]="banner.departmentNumber" placeholder="请输入部门编码">
            </div>
        </div>
        <div class="form-group row">
            <label class="col-sm-2 col-form-label label-required text-right" style="padding-right: 0px;">排序号</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" [(ngModel)]="banner.sortNumber" placeholder="请输入排序号">
            </div>
        </div>
        <div class="form-group row">
            <label class="col-sm-2 col-form-label label-required text-right" style="padding-right: 0px;">备注</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" [(ngModel)]="banner.note" placeholder="请输入备注">
            </div>
        </div>
        <div class="modal-footer" style="justify-content: center;">
            <button (click)="modal.dismiss()" type="button" class="btn" style="background-color: #eaf4ff;
        border-color: #dae0e5;color: #000;width: 18%;margin-right: 1.25rem;">取消</button>
            <button tsBtn loading (submit)="confirmSave($event)" style="background-color: #387ddd;width: 18%;
        border-color: #387ddd;" color="success">保存</button>
        </div>
    </div>`
})
export class ModaltwoComponent {

    conpay = new Array<any>();
    pagination = new Pagination();
    search = new SearchParams({ status: '', uid: '', orderSn: '' });
    loading = false;
    uploading = false;
    userInfo: any;
    banner: Recharge = { id: 0 };
    constructor(
        public global: GlobalService,
        public modal: ModalService,
        private rechargeService: RechargeService,
        private auth: AuthService,
    ) {
        console.log(this.auth.user);
    }
    /**
     *部门增改
     * @param btn
     */
    confirmSave(btn: any) {
        (this.banner.id > 0 ? this.rechargeService.updateBanner(this.banner) : this.rechargeService.insertBanner(this.banner))
            .subscribe({
                next: () => this.modal.close(),
                complete: () => btn.dismiss()
            });
    }
    // coanpayList() {
    //     this.userInfo = this.auth.user;
    //     this.rechargeService.company()
    //         .subscribe({
    //             next: res => {
    //                 this.conpay = res.datas;

    //             },
    //             complete: () => this.loading = false
    //         });
    // }


}


